const Stack = require("./stackDefine");
// 10进制转2进制或8进制
function convertToBinary(num,base) {
  let stack = new Stack();
  do {
    let val =Math.floor(num / base) ;
    stack.push(num % base); //取余数
    num = val;
  } while (num >= 1);
  return stack;
}
// 测试
let stack = convertToBinary(87,8);
let binary = [];
while (stack.length() >= 1) {
  const element = stack.pop();
  binary.push(element);
}
console.log(binary.join(","));
